package cn.argentoaskia.crm.service.delete.impl;

import cn.argentoaskia.crm.dao.EmployeeDAO;
import cn.argentoaskia.crm.service.delete.EmployeeDeleteService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service
public class EmployeeDeleteServiceImpl implements EmployeeDeleteService {

    @Autowired
    private EmployeeDAO employeeDAO;
    @Override
    public boolean deleteIds(String idsJson) {
        //JSONArray
        // 1.把json转为Integer[]
        JSONObject jsonObject = JSONObject.parseObject(idsJson);
        Integer[] integers = jsonObject.getObject("ids", Integer[].class);

        // 2.调用deleteDao删除数据
        int i = employeeDAO.deleteIds(integers);
        // 3.判断删除成功还是失败
        // 删除失败
        return i > 0;     // 删除成功
    }
}
